package exception;

import java.util.Scanner;

public class ThrowAndCatch{

    public static void check(int sw)throws Exception{
        switch(sw){
            case 1:throw new Exception("发生检查异常！！");
            case 2:throw new RuntimeException("发生非检查异常");
        }
    }
    //调用check
    public static void test(int sw) throws Exception {
        check(sw);
    }

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);
        System.out.println("sw: ");
        int sw=stdIn.nextInt();
        try {
            test(sw);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }


}
